//package dsk.demo.product.controller.automarket;
//
//import cn.hutool.core.date.DateTime;
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.http.HttpUtil;
//import cn.hutool.json.*;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import dsk.demo.product.dao.GWeekPriceDao;
//import dsk.demo.product.entity.gupiao.GWeekPrice;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.HashMap;
//import java.util.LinkedHashMap;
//import java.util.Map;
//
///**
// * @ClassName TestTe
// * @Author 戴世坤
// * @Date 2025/9/5 21:18
// */
//public class TestTe {
//
//    public static void main(String[] args) {
//        String ret = HttpUtil.get("https://sqt.gtimg.cn/q=sh512890");
//
//        String result = ret.split("\"")[1];
//        String[] split = result.split("~");
//
//        Map<String, String> resMap  = new LinkedHashMap<>();
//        int index = 0;
//        for (String s : split) {
//            resMap.put(index + "", s);
//            index++;
//        }
//
//        System.out.println("股票名称:" + split[1]);
//        System.out.println("股票代码:" + split[2]);
//        System.out.println("最新价:" + split[3]);
//        System.out.println("昨日收盘价:" + split[4]);
//        System.out.println("开盘价:" + split[5]);
//        System.out.println("最高价:" + split[33]);
//        System.out.println("最低价:" + split[34]);
//        System.out.println("涨跌金额:" + split[31]);
//        System.out.println("涨跌幅:" + split[32]);
//    }
//    private GWeekPriceDao weekPriceDao;
////
////    public void main(String[] args) {
////        String ret = HttpUtil.get("https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get?param=sh512890,week,,,320,qfq&type=qfq&_var=kline_weekqfq");
////        JSONObject object = JSONUtil.parseObj(ret.split("=")[1]);
////        JSONArray jsonArray = object.getJSONObject("data").getJSONObject("sh512890").getJSONArray("qfqweek");
////
////
////        // 最新一周的数据
////        JSONArray lastData = (JSONArray)jsonArray.get(jsonArray.size() - 1);
////        // 一周前数据
////        JSONArray oneWeekAgo = (JSONArray)jsonArray.get(jsonArray.size() - 2);
////
////        GWeekPrice build = GWeekPrice.builder()
////                .thscode("512890.SH")
////                .time(lastData.getDate(0))
////                .thsOpenWFund(lastData.getBigDecimal(1))
////                .thsCloseWFund(lastData.getBigDecimal(2))
////                .thsHighWFund(lastData.getBigDecimal(3))
////                .thsLowWFund(lastData.getBigDecimal(4))
////                .thsChgWFund(lastData.getBigDecimal(2).subtract(oneWeekAgo.getBigDecimal(2)))
////                .thsChgRatioWFund(lastData.getBigDecimal(2).subtract(oneWeekAgo.getBigDecimal(2))
////                        .divide(oneWeekAgo.getBigDecimal(2), 6, RoundingMode.HALF_UP)
////                        .multiply(new BigDecimal("100")))
////                .build();
////
////        DateTime dateTime = DateUtil.beginOfWeek(build.getTime());
////        GWeekPrice gWeekPrice = weekPriceDao.selectOne(Wrappers.<GWeekPrice>lambdaQuery().ge(GWeekPrice::getTime, dateTime));
////        if (gWeekPrice != null) {
////            build.setId(gWeekPrice.getId());
////            weekPriceDao.updateById(build);
////        } else {
////            weekPriceDao.insert(build);
////        }
////        System.out.println("最新一周的周线数据:" + JSONUtil.toJsonStr(build, JSONConfig.create().setDateFormat("yyyy-MM-dd")));
////    }
//
//
//}
